
import pandas as pd
import csv
import numpy as np

import datetime
from scipy.spatial import distance


data= pd.DataFrame(pd.read_csv('infos_feature_new.csv',skiprows=1,header=None))


d = [0] * len(data)
d1 = [0] * len(data)
ed = [0] * len(data)
ed1 = [0] * len(data)

dicts={}

with open('ced.csv','w',encoding='utf-8',newline='\n') as fr:
  writer=csv.writer(fr)
  for i in range(75000):
      print(i)
      print(datetime.datetime.now())
      td = 9999999
      td1 = 9999999
      ti = i
      ti1 = i
      for j in range(len(data)-1):
          if data.iat[i, 0]!=data.iat[j, 0] or i == j or data.iat[i, 14]==data.iat[j, 14]:
              continue
          #temp = distance.euclidean(data.iloc[i:i + 1, 18:], data.iloc[j:j + 1, 18:])
          temp= np.linalg.norm(data.iloc[i:i + 1, 23:].to_numpy() - data.iloc[j:j + 1, 23:].to_numpy())
          if td > temp:
              td1 = td
              ti1 = ti
              td = temp
              ti = j
          elif td1 > temp:
              td1 = temp
              ti1 = j
      writer.writerow([i,ti,data.iat[ti, 14],td,ti1,data.iat[ti1, 14],td1])